# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from getJobs.lib.EasySqlite3 import EasySqlite
from itemadapter import ItemAdapter

class save2db:
    _db = None
    def open_spider(self, spider):
        self._db = EasySqlite('jobs.db')

    def process_item(self, item, spider):
        print("%s (%s)"%(item['name'], item['pay']))
        self._db.table('jobs').insert(dict(item))
        self._db.commit()
        return item
    
    def close_spider(self, spider):
        pass